package mystruct

import (
	"time"

	"gorm.io/gorm"
)

// 公共字段
type MODEL struct {
	ID        uint           `gorm:"primarykey;autoIncrement" json:"ID"` // 主键ID
	CreatedAt time.Time      `gorm:"autoCreateTime" json:"created_at"`
	UpdatedAt time.Time      `gorm:"autoUpdateTime" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"index" json:"-"` // 删除时间
}

// User 定义用户结构体
type User struct {
	MODEL
	Username          string    `gorm:"type:varchar(255)" json:"username"`
	Email             string    `gorm:"unique;not null" json:"email"`
	PhoneNumber       string    `gorm:"type:varchar(20)" json:"phone_number"`
	Gender            string    `gorm:"type:enum('male', 'female', 'other');default:'male'" json:"gender"`
	AvatarURL         string    `gorm:"type:varchar(255)" json:"avatar_url"`
	Role              string    `gorm:"type:enum('user', 'admin', 'vip');default:'user'" json:"role"`
	Status            string    `gorm:"type:enum('active', 'frozen', 'deleted');default:'active'" json:"status"`
	LastLoginTime     time.Time `gorm:"type:timestamp" json:"last_login_time"`
	OtpSecret         string    `gorm:"type:varchar(255)" json:"otp_secret"`
	LoginFailureCount int       `gorm:"default:0" json:"login_failure_count"`
	UserLevel         int       `gorm:"default:1" json:"user_level"`
	ClientId          string    `gorm:"type:varchar(255)" json:"client_id"`
}
